﻿
Imports osi.root.lock
Imports osi.root.lock.slimlock
Imports osi.root.connector

Partial Public MustInherit Class _pointer(Of T)
    Shared Sub New()
        Dim tp As Type = Nothing
        tp = GetType(T)
        If tp.IsValueType() Then
            k_assert(Not tp.implement(Of ilock)())
            k_assert(Not tp.implement(Of islimlock)())
            k_assert(Not tp Is GetType(singleentry))
        End If
    End Sub

    Public Sub New()
        clear()
    End Sub

    Public Sub New(ByVal i As T)
        [set](i)
    End Sub

    Public Sub New(ByVal i As _pointer(Of T))
        If i Is Nothing Then
            clear()
        Else
            [set](+i)
        End If
    End Sub

    Public MustOverride Sub [set](ByVal i As T)
    Public MustOverride Function [get]() As T
    Public MustOverride Sub clear()

    Protected Overridable Function compare(ByVal i As T, ByVal j As T) As Int32
        Return connector.compare(i, j)
    End Function
End Class
